using System;
using System.Collections.Generic;
using System.IO;
using System.Windows.Forms;

namespace WeChatFileManagementWinApp
{
    /// <summary>
    /// 设置管理器，负责管理应用程序设置和搜索结果的持久化
    /// </summary>
    public class SettingsManager
    {
        private readonly DatabaseManager _databaseManager;

        /// <summary>
        /// 初始化设置管理器
        /// </summary>
        public SettingsManager()
        {
            string dbPath = Path.Combine(
               Application.StartupPath,
                "WeChatFileManagement.db"
            );
            _databaseManager = new DatabaseManager(dbPath);
        }

        /// <summary>
        /// 保存搜索目录列表
        /// </summary>
        /// <param name="directories">目录列表</param>
        public void SaveSearchDirectories(List<string> directories)
        {
            _databaseManager.SaveSearchDirectories(directories);
        }

        /// <summary>
        /// 加载搜索目录列表
        /// </summary>
        /// <returns>目录列表</returns>
        public List<string> LoadSearchDirectories()
        {
            return _databaseManager.LoadSearchDirectories();
        }

        /// <summary>
        /// 保存搜索结果
        /// </summary>
        /// <param name="files">文件列表</param>
        public void SaveSearchResults(List<WeChatFile> files)
        {
            _databaseManager.SaveSearchResults(files);
        }

        /// <summary>
        /// 加载搜索结果
        /// </summary>
        /// <returns>文件列表</returns>
        public List<WeChatFile> LoadSearchResults()
        {
            return _databaseManager.LoadSearchResults();
        }
    }
}